<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.ViewData.MenuNewViewData>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Create Community Menu</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
   <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $("#MenuForm").validate({
                rules:
            {
                MenuName:
                {
                    required: true
                },
                Link:
                {
                    required: true
                },
                SortOrder:
                {
                    required: true,
                    digits: true
                }
            },

                messages:
            {
                MenuName:
                {
                    required: "Menu name must be entered"
                },
                Link:
                {
                    required: "Link must be entered"
                },
                SortOrder:
                {
                    required: "Sort Order must be entered",
                    digits: "Sort Order must be only digits"
                }
            }
            });
        });
    </script>

    <h2>
        Create Community Menu</h2>
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("CreateCommunityMenu", "Menu", FormMethod.Post, new { id = "MenuForm", enctype = "multipart/form-data" }))
       {%>
    <fieldset>
        <legend>Create Community Menu</legend>
        <p>
            <label for="CommunityName">
                Community:</label>
            <%= Html.TextBox("CommunityName", ViewData.Model.Community.Name, new { disabled = "disabled" })%>
            <%= Html.Hidden("CommunityId") %>
        </p>
        <p>
            <label for="MenuName">
                Menu name:</label>
            <%= Html.TextBox("MenuName") %>
            <%= Html.ValidationMessage("MenuName", "*") %>
        </p>
        <p>
            <label for="Link">
                Link:</label>
            <%= Html.TextBox("Link") %>
            <%= Html.ValidationMessage("Link", "*") %>
        </p>
        <p>
            <label for="IsRoot">
                Is root menu:</label>
            <%= Html.CheckBox("IsRoot")%>
        </p>
        <p>
            <label for="ParentMenuId">
                or is child of parent menu:</label>
            <%= Html.DropDownList("ParentMenuId",new SelectList(ViewData.Model.Parents, "MenuId", "MenuName"))%>
            <%= Html.ValidationMessage("ParentMenuId", "*") %>
        </p>
        <p>
            <label for="SortOrder">
                Sort Order:</label>
            <%= Html.TextBox("SortOrder") %>
            <%= Html.ValidationMessage("SortOrder", "*") %>
        </p>
        <p>
            <label for="Active">
                Active:</label>
            <%= Html.CheckBox("Active") %>
            <%= Html.ValidationMessage("Active", "*") %>
        </p>
        <p>
            <label for="Desc">
                Description:</label>
            <%= Html.TextArea("Desc") %>
            <%= Html.ValidationMessage("Desc", "*") %>
        </p>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
